package com.sailing.face.controller;

import com.alibaba.fastjson.JSONObject;
import com.sailing.face.dto.ResponseResult;
import com.sailing.face.service.FaceImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/face")
public class FaceImageController {

    @Autowired
    private FaceImageService faceImageService;

    @PostMapping(value = "retrieval")
    public ResponseResult analysisFaceImage(@RequestBody JSONObject jsonObject) throws Exception{
        String picture_image_content_base64 = jsonObject.getString("picture_image_content_base64");
        String repository_id = jsonObject.getString("repository_id");
        if(StringUtils.isEmpty(picture_image_content_base64)){
            throw new Exception();
        }
        return faceImageService.analysisFaceImage(picture_image_content_base64,repository_id);
    }
}
